package com.gec.hawaste.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gec.hawaste.entity.WorkOrderDo;
import com.gec.hawaste.service.IWorkOrderService;
import com.gec.hawaste.utils.PageInfo;
import com.gec.hawaste.utils.ResultBean;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author gec
 * @since 2022-11-23
 */
@RestController
@RequestMapping("/manager/work")

public class WorkOrderController {
    @Autowired
    private IWorkOrderService workOrderService;

    @RequiresPermissions("work:select")
    @GetMapping("/select/{current}/{size}")
    public ResultBean<Page> select(@PathVariable Integer current,
                                   @PathVariable Integer size,
                                   @RequestParam Map<String, Object> params) {
        PageInfo<WorkOrderDo> page = (PageInfo<WorkOrderDo>) workOrderService.selectByCondition(new PageInfo<WorkOrderDo>(current, size), params);
        page.setNavigatePage();
        return ResultBean.ok(page);
    }

    @RequiresPermissions("work:select")
    @GetMapping("/selectOne/{oid}")
    public ResultBean selectOne(@PathVariable Long oid) {
        return ResultBean.ok(workOrderService.selectDetailById(oid));
    }
}
